# %%
import requests
from lxml import etree
url='https://www.quanben.so/top/allvisit/'
headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'}
resp=requests.get(url,headers=headers)
# print(resp.text)
e=etree.HTML(resp.text)
types=e.xpath('//div[@class="novelslistss"]/li/span[1]/text()')
names=e.xpath('//div[@class="novelslistss"]/li/span[2]/a/@title')
dates=e.xpath('//div[@class="novelslistss"]/li/span[5]/text()')
authors=e.xpath('//div[@class="novelslistss"]/li/span[4]/text()')
datas=[]
for t,n,a,d in zip(types,names,authors,dates):
    # print(f"{t}--{n}--{c}--{a}")
    datas.append([t,n,a,d])
# %%
import pandas as pd
df=pd.DataFrame(datas,columns=['类型','名字','作者','日期'])
# print(df)
df
# %%
df.describe()
# %%
df.groupby('类型').count()
# %%
import matplotlib
df.类型.hist()
# %%
df[df.类型=='玄幻小说'].sort_values(by='日期')

# %%
df['日期']=df['日期'].astype('int')

# %%
